import React, { useEffect, useState } from 'react'
import { connect } from 'react-redux'

function Count(props) {
  console.log(props)
  return (
    <div>
      <p>{props.c}</p>
      <button
        onClick={() => {
          props.dispatch({ type: 'increment' })
        }}
      >
        +
      </button>
      <button
        onClick={() => {
          props.dispatch({ type: 'decrement' })
        }}
      >
        -
      </button>
    </div>
  )
}

// 给Count创建父组件
function mapStateToProps(state) {
  return {
    c: state.count,
  }
}
const WithCount = connect(mapStateToProps)(Count)
export default WithCount

/*

以前写的高阶组件
function fn(){
    return class xxx extends Component{

    }
}

connect: 
function connect(){
    return function(){
        return class Far extends Component {

        }
    }
}


*/
